package com.yida.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yida.service.serverphoto;

@Controller
public class adminPhotoDelete {

	@Autowired
	serverphoto service;
	
	@RequestMapping("/admin/photodelete")
	@ResponseBody
	public Object photo(Integer id,String imgurl) throws JsonProcessingException {
	    
		boolean result =   service.photodelete(id, imgurl);
		
		if (result) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("result", "true");	
			ObjectMapper josnMapper = new ObjectMapper();
			String jsonString = josnMapper.writeValueAsString(map);
			
			return jsonString;
		}else {
			Map<String, String> map = new HashMap<String, String>();
			map.put("result", "false");	
			ObjectMapper josnMapper = new ObjectMapper();
			String jsonString = josnMapper.writeValueAsString(map);
			return jsonString;
		}
		
     
	}
	
	
}
